home *** CD-ROM | disk | FTP | other *** search
/ IRIX Installation Tools & Overlays 2002 November / SGI IRIX Installation Tools & Overlays 2002 November - Disc 4.iso / dist / cluster_admin.idb / etc / init.d / cluster.z / cluster
Text File  |  2002-10-15  |  9KB  |  304 lines

  1. #! /sbin/sh
  2. #                                                                         
  3. #  Copyright (C) 1998, Silicon Graphics, Inc.                             
  4. #  All Rights Reserved.                                                   
  5. #                                                                         
  6. #  UNPUBLISHED -- Rights reserved under the copyright laws of the United  
  7. #  States.  Use of a copyright notice is precautionary only and does not  
  8. #  imply publication or disclosure.                                       
  9. #                                                                         
  10. #  THIS SOFTWARE CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION OF     
  11. #  SILICON GRAPHICS, INC. ANY DUPLICATION, MODIFICATION, DISTRIBUTION, OR 
  12. #  DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR EXPRESS WRITTEN    
  13. #  PERMISSION OF SILICON GRAPHICS, INC.                                   
  14. #                                                                         
  15. #  U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND                               
  16. #  Use, duplication or disclosure by the Government is subject to         
  17. #  restrictions as set forth in FAR 52.227.19(c)(2) or subparagraph       
  18. #  (c)(1)(ii) of the Rights in Technical Data and Computer Software       
  19. #  clause at DFARS 252.227-7013 and/or in similar or successor clauses    
  20. #  in the FAR, or the DOD or NASA FAR Supplement.  Unpublished-- rights   
  21. #  reserved under the copyright laws of the United States.                
  22. #  Contractor/manufacturer is Silicon Graphics, Inc.,                     
  23. #  2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.                 
  24. #
  25. #
  26. # Cluster Services control
  27. #
  28. # "$Id: cluster-init.d,v 1.30 2002/08/05 15:32:29 dxm.longdrop.melbourne.sgi.com Exp $"
  29.  
  30. BIN=/usr/cluster/bin
  31. LBIN=/usr/lib32/cluster/cbe
  32.  
  33. if /etc/chkconfig verbose; then
  34.     ECHO=echo
  35. else
  36.     ECHO=:
  37. fi
  38.  
  39. SIGTERM_TMOUT=5;
  40.  
  41. # cmond command timeout: 30 seconds 
  42. CMON_TMOUT=30
  43.  
  44. CMON_START="/usr/cluster/bin/cmon_ctrl start -r -t ${CMON_TMOUT} -g"
  45. CMON_STOP="/usr/cluster/bin/cmon_ctrl stop -r -f -t ${CMON_TMOUT} -g"
  46. CMON_RESTART="/usr/cluster/bin/cmon_ctrl restart -r -f -t ${CMON_TMOUT} -g"
  47. CMON_EXIT="/usr/cluster/bin/cmon_ctrl exit -r -t ${CMON_TMOUT} -f"
  48. CLUSTER_CONTROL_GRP=cluster_control
  49. CLUSTER_ADMIN_GRP=cluster_admin
  50. CLUSTER_CX_GRP=cluster_cx
  51.  
  52. FS2D_CAPS='CAP_NETWORK_MGT,CAP_SCHED_MGT,CAP_PRIV_PORT+ip'
  53. CMOND_CAPS='CAP_NETWORK_MGT,CAP_SYSINFO_MGT,CAP_PRIV_PORT,CAP_PROC_MGT+ip'
  54.  
  55. case $1 in
  56.     'start')
  57.     if /etc/chkconfig cluster; then
  58.         $ECHO "Cluster services:\c"
  59.  
  60.         # Check for license
  61.         if /etc/chkconfig cxfs_cluster; then
  62.         if $BIN/cxfslicense; then
  63.             echo "CXFS not properly licensed for this host.  Run"
  64.             echo "\t'$BIN/cxfslicense -d'"
  65.             echo "for detailed failure information.  After fixing the"
  66.             echo "license, please run '/etc/init.d/cluster restart'."
  67.             # Not exiting so clconfd will try to start and 
  68.             # place a similar error message in the SYSLOG
  69.         fi
  70.         fi
  71.         # Start fs2d explicitly, before any of its clients start.
  72.         /sbin/killall -0 fs2d > /dev/null 2>&1
  73.         if [ $? -ne 0 ]; then
  74.         /sbin/rm -f /var/cluster/cdb/cdb.db#/##dblock > /dev/null 2>&1
  75.         /sbin/suattr -C "$FS2D_CAPS" -c \
  76.                     "$LBIN/fs2d /var/cluster/cdb/cdb.db \# | cat > /dev/null"
  77.         $ECHO " fs2d\c"
  78.         fi
  79.  
  80.         /sbin/killall -0 cmond > /dev/null 2>&1
  81.         if [ $? -ne 0 ]; then
  82.         #
  83.         # CAD uses lots of file descriptors. Not all file
  84.         # descriptors are open at the same time.
  85.         #
  86.         limit descriptors 2500
  87.         /sbin/suattr -C "$CMOND_CAPS" -c \
  88.                     "$BIN/cmond `cat /etc/config/cmond.options 2>/dev/null`"
  89.         $ECHO " cmond\c"
  90.         fi
  91.  
  92.         # Wait for cmond to start, sleep for 1 second.
  93.         /sbin/sleep 1;
  94.  
  95.         # Starting cluster admin group processes. We will attempt
  96.         # to start cad 5 times since cmond takes time to start
  97.         # accepting requests.
  98.         try_cnt=0
  99.         while true; do 
  100.         try_cnt=`expr $try_cnt + 1`
  101.         ${CMON_START} ${CLUSTER_ADMIN_GRP} > /dev/null 2>&1;
  102.         start_status=$?
  103.         if [ $try_cnt -ge 5 -o $start_status -eq 0 ]; then
  104.             break;
  105.         fi
  106.         /sbin/sleep 2;
  107.         done
  108.         if [ $start_status -ne 0 ]; then
  109.         echo "Cluster admin processes could not be started."
  110.         echo "Please run /etc/init.d/cluster restart."
  111.         exit 1;
  112.         else
  113.         $ECHO " cad\c"
  114.         fi
  115.  
  116.         # Starting cluster control group processes
  117.         ${CMON_START} ${CLUSTER_CONTROL_GRP} > /dev/null 2>&1;
  118.         if [ $? -ne 0 ]; then
  119.         echo "Cluster control processes could not be started."
  120.         echo "Please run /etc/init.d/cluster restart."
  121.         exit 1;
  122.         else
  123.         $ECHO " crsd\c"
  124.         fi
  125.  
  126.         $ECHO "."
  127.     fi
  128.  
  129.     if /etc/chkconfig cxfs_cluster; then
  130.         $ECHO "CXFS Cluster services:\c"
  131.  
  132.         if /etc/chkconfig cluster; then
  133.  
  134.         # Starting cluster CX group processes
  135.         ${CMON_START} ${CLUSTER_CX_GRP} > /dev/null 2>&1;
  136.         if [ $? -ne 0 ]; then
  137.             echo "Cluster CX processes could not be started."
  138.             echo "Please run /etc/init.d/cluster restart."
  139.             exit 1;
  140.         else
  141.             $ECHO " clconfd\c"
  142.         fi
  143.  
  144.         $ECHO "."
  145.  
  146.         else
  147.         echo "CXFS cluster services can not run without the basic"
  148.         echo "cluster services."
  149.         echo "Please run /etc/chkconfig cluster on."
  150.         exit 1;
  151.         fi
  152.  
  153.     fi
  154.     ;;
  155.  
  156.     'stop')
  157.     # 
  158.     # If cmond is not running, send SIGTERM to all cluster processes.
  159.     #
  160.     /sbin/killall -0 cmond > /dev/null 2>&1
  161.     if [ $? -ne 0 ]; then
  162.         /sbin/killall -k ${SIGTERM_TMOUT} cmond;
  163.         /sbin/killall -k ${SIGTERM_TMOUT} cad crsd;
  164.         if /etc/chkconfig cxfs_cluster; then
  165.         /sbin/killall -k ${SIGTERM_TMOUT} clconfd;
  166.         fi
  167.     else
  168.         if /etc/chkconfig cxfs_cluster; then
  169.         # Stopping cluster CX group processes
  170.         ${CMON_STOP} ${CLUSTER_CX_GRP} > /dev/null 2>&1;
  171.         if [ $? -ne 0 ]; then
  172.             echo "Cluster CX processes could not be stopped"
  173.             exit 1;
  174.         fi
  175.         fi
  176.  
  177.         # Stopping cluster control group processes
  178.         ${CMON_STOP} ${CLUSTER_CONTROL_GRP} > /dev/null 2>&1;
  179.         if [ $? -ne 0 ]; then
  180.         echo "Cluster control process could not be stopped"
  181.         exit 1;
  182.         fi
  183.  
  184.         # Stopping cluster admin processes
  185.         ${CMON_STOP} ${CLUSTER_ADMIN_GRP} > /dev/null 2>&1;
  186.         if [ $? -ne 0 ]; then
  187.         echo "Cluster admin process could not be stopped"
  188.         exit 1;
  189.         fi
  190.  
  191.         # Stopping cmond process
  192.         ${CMON_EXIT} > /dev/null 2>&1;
  193.         if [ $? -ne 0 ]; then
  194.         echo "cmond process could not be stopped"
  195.         exit 1;
  196.         fi
  197.     fi
  198.  
  199.      # Kill fs2d in the end. 
  200.       /sbin/killall -0 fs2d > /dev/null 2>&1
  201.     if [ $? -eq 0 ]; then
  202.         /sbin/killall -k {SIGTERM_TMOUT} fs2d;
  203.     fi
  204.  
  205.     ;;
  206.  
  207.     'restart')
  208.     if /etc/chkconfig cluster; then
  209.         $ECHO "Restarting cluster services..."
  210.  
  211.         # Check for license
  212.         if /etc/chkconfig cxfs_cluster; then
  213.         if $BIN/cxfslicense; then
  214.             echo "CXFS not properly licensed for this host.  Run"
  215.             echo "\t'$BIN/cxfslicense -d'"
  216.             echo "for detailed failure information."
  217.             # Not exiting so clconfd will try to start and 
  218.             # place a similar error message in the SYSLOG
  219.         fi
  220.         fi
  221.         # Start fs2d explicitly, before any of its clients start.
  222.         /sbin/killall -0 fs2d > /dev/null 2>&1
  223.         if [ $? -ne 0 ]; then
  224.         /sbin/rm -f /var/cluster/cdb/cdb.db#/##dblock > /dev/null 2>&1
  225.         /sbin/suattr -C "$FS2D_CAPS" -c \
  226.                     "$LBIN/fs2d /var/cluster/cdb/cdb.db \# | cat > /dev/null"
  227.  
  228.         fi
  229.  
  230.         # Check if cmond is running
  231.         /sbin/killall -0 cmond > /dev/null 2>&1
  232.         if [ $? -ne 0 ]; then
  233.         #
  234.         # CAD uses lots of file descriptors. Not all file
  235.         # descriptors are open at the same time.
  236.         #
  237.         limit descriptors 2500
  238.         /sbin/suattr -C "$CMOND_CAPS" -c \
  239.                     "$BIN/cmond `cat /etc/config/cmond.options 2>/dev/null`"
  240.  
  241.         # Wait for cmond to start. sleep for 5 seconds.
  242.         /sbin/sleep 5;
  243.  
  244.         # Starting cluster admin group processes
  245.         ${CMON_START} ${CLUSTER_ADMIN_GRP} > /dev/null 2>&1;
  246.         if [ $? -ne 0 ]; then
  247.             echo "Cluster admin processes could not be restarted"
  248.             exit 1;
  249.         fi
  250.  
  251.         # Starting cluster control group processes
  252.         ${CMON_START} ${CLUSTER_CONTROL_GRP} > /dev/null 2>&1;
  253.         if [ $? -ne 0 ]; then
  254.             echo "Cluster control processes could not be restarted"
  255.             exit 1;
  256.         fi
  257.  
  258.         if /etc/chkconfig cxfs_cluster; then
  259.             # Starting cluster CX group processes
  260.             ${CMON_START} ${CLUSTER_CX_GRP} > /dev/null 2>&1;
  261.             if [ $? -ne 0 ]; then
  262.             echo "Cluster CX processes could not be restarted"
  263.             exit 1;
  264.             fi
  265.         fi
  266.  
  267.         else
  268.         # Make cmond reread configuration
  269.         /sbin/killall -HUP cmond
  270.  
  271.         # Restarting cluster admin group processes
  272.         ${CMON_RESTART} ${CLUSTER_ADMIN_GRP} > /dev/null 2>&1;
  273.         if [ $? -ne 0 ]; then
  274.             echo "Cluster admin processes could not be restarted"
  275.             exit 1;
  276.         fi
  277.  
  278.         # Restarting cluster control group processes
  279.         ${CMON_RESTART} ${CLUSTER_CONTROL_GRP} > /dev/null 2>&1;
  280.         if [ $? -ne 0 ]; then
  281.             echo "Cluster control processes could not be restarted"
  282.             exit 1;
  283.         fi
  284.  
  285.         if /etc/chkconfig cxfs_cluster; then
  286.             # Restarting cluster CX group processes
  287.             ${CMON_RESTART} ${CLUSTER_CX_GRP} > /dev/null 2>&1;
  288.             if [ $? -ne 0 ]; then
  289.             echo "Cluster CX processes could not be restarted"
  290.             exit 1;
  291.             fi
  292.         fi
  293.         fi
  294.     else
  295.         echo "cluster services are not currently configured on"
  296.         exit 1;
  297.     fi
  298.     ;;
  299.  
  300.     *)
  301.     echo "usage: /etc/init.d/cluster {start|stop|restart}"
  302.     ;;
  303. esac
  304.